mixin breadcrumbs(items)
    .breadcrumb-wrapper.col-12
        ol.breadcrumb
            each obj, i in items
                if (i === items.length - 1)
                    li.breadcrumb-item.active
                        if (obj.url)
                            a(href=obj.url)= obj.name
                        else
                            = obj.name
                else
                    li.breadcrumb-item
                        if (obj.url)
                            a(href=obj.url)= obj.name
                        else
                            a(href='#')= obj.name
        
mixin verticalMenu(items)
    //- Main navigation ul
    ul#main-menu-navigation.navigation.navigation-main(data-menu="menu-navigation")
        //- Loop through each menu item
        each menu, i in items
            //- check if classlist exist for list item
            - var classlist = (menu.classlist !== undefined) ? menu.classlist : ''
            - var translation = (menu.i18n !== undefined) ? menu.i18n : ''
            //- If menu item is navigation header
            if (menu.navheader)
                li(class=classlist +" navigation-header")
                    if (translation != '')
                        span(data-i18n=translation)= menu.navheader
                    else
                        span= menu.navheader
                    i(class=menu.icon + " ft-minus" data-toggle='tooltip', data-placement='right', data-original-title=menu.navheader)
            else
                if (activeMenu == menu.slug)
                    - var menuActive = true
                else
                    - var menuActive = false

                li(class=menuActive ? 'active' : '' + classlist + " nav-item")
                    a(href=menu.url)
                        i(class=menu.icon)
                        if (trasnlation != '')
                            span(class="menu-title" data-i18n=translation)= menu.name
                            if (menu.tag)
                                if (menu.tagcustom)
                                    span(class="badge" class=menu.tagcustom)= menu.tag
                        else
                            span.menu-title= menu.name
                            if (menu.tag)
                                if (menu.tagcustom)
                                    span(class="badge" class=menu.tagcustom)= menu.tag
                        if (menu.menuSubtitle)
                            span.tag.menu-sub-title= menu.menuSubtitle

                    //- 1st Level submenu HTML
                    if (menu.submenu)
                        +verticalSubMenu(menu.submenu)

mixin verticalSubMenu(items)
    ul.menu-content
        each submenu, j in items
            //- check if classlist exist for list item
            - var classlist1 = (submenu.classlist !== undefined) ? submenu.classlist : ''
            - var translation1 = (submenu.i18n !== undefined) ? submenu.i18n : ''
            if (submenu.divider)
                li(class="navigation-divider")
            else
                if (activeMenu == submenu.slug)
                    - var submenuActive1 = true
                else
                    - var submenuActive1 = false
                li(class=submenuActive1 ? 'active' : '' + classlist1)
                    if (translation1 != '')
                        a(href=submenu.url data-i18n=translation1 class="menu-item")= submenu.name
                    else
                        a(href=submenu.url class="menu-item")= submenu.name
                        if (submenu.menuSubtitle)
                            span.tag.menu-sub-title= submenu.menuSubtitle

                    if (submenu.submenu)
                        +verticalSubMenu(submenu.submenu)

mixin horizontalMenu(items)
    //- Main navigation ul
    ul(id="main-menu-navigation" class="nav navbar-nav" data-menu="menu-navigation")
        //- Loop through each menu item
        each menu, i in items
            //- check if classlist exist for list item
            - var classlist = (menu.classlist !== undefined) ? menu.classlist : ''
            - var translation = (menu.i18n !== undefined) ? menu.i18n : ''
            if (activeMenu == menu.slug)
                - var menuActive = true
            else
                - var menuActive = false

            if (menu.megamenu)
                li(class="dropdown mega-dropdown nav-item" class=classlist class=menuActive ? 'active' : '' data-menu="megamenu")
                    a(href=menu.url data-toggle='dropdown' class="dropdown-toggle nav-link")
                        i(class=menu.icon)
                        if (translation != '')
                            span(data-i18n=translation)= menu.name
                        else
                            span= menu.name
                        if (menu.tag)
                            if (menu.tagcustom)
                                span(class="badge" class=menu.tagcustom)= menu.tag
                        if (menu.menuSubtitle)
                            span.tag.menu-sub-title= menu.menuSubtitle
                    if (menu.megaMenuCols)
                        +megaMenuColumns(menu.megaMenuCols)
            else if (menu.dropdown)
                //- If dropdown menu
                li(class="dropdown nav-item" class=classlist class=menuActive ? 'active' : '' data-menu="dropdown")
                    a(href=menu.url data-toggle='dropdown' class="dropdown-toggle nav-link")
                        i(class=menu.icon)
                        if (translation != '')
                            span(data-i18n=translation)= menu.name
                        else
                            span= menu.name
                        if (menu.tag)
                            if (menu.tagcustom)
                                span(class="badge" class=menu.tagcustom)= menu.tag
                        if (menu.menuSubtitle)
                            span.tag.menu-sub-title= menu.menuSubtitle
                    //- 1st Level submenu HTML
                    if (menu.submenu)
                        +dropdownMenuSubItems(menu.submenu)
            else
                li(class="nav-item" class=classlist class=menuActive ? 'active' : '')
                    a(href=menu.url class="nav-link")
                        i(class=menu.icon)
                        if (translation != '')
                            span(data-i18n=translation)= menu.name
                        else
                            span= menu.name
                        if (menu.tag)
                            if (menu.tagcustom)
                                span(class="badge" class=menu.tagcustom)= menu.tag
                        if (menu.menuSubtitle)
                            span.tag.menu-sub-title= menu.menuSubtitle

mixin megaMenuColumns(items)
    ul.mega-dropdown-menu.dropdown-menu.row
        each megaMenuCol, j in items
            li(class=megaMenuCol.colClass data-mega-col=megaMenuCol.colClass )
                if (megaMenuCol.colTitle)
                    h6(class="dropdown-menu-header text-uppercase" data-toggle='dropdown')
                        i(class=megaMenuCol.icon)
                        = megaMenuCol.colTitle
                if (megaMenuCol.megaMenu)
                    ul.drilldown-menu
                        li.menu-list
                            +megaMenuSubItems(megaMenuCol.megaMenu)

mixin megaMenuSubItems(items)
    ul.mega-menu-sub
        each megaMenu, j in items
            //- check if classlist exist for list item
            - var classlist = (megaMenu.classlist !== undefined) ? megaMenu.classlist : ''
            if (megaMenu.divider)
                li(class="dropdown-divider")
            else
                if (activeMenu == megaMenu.slug)
                    - var menuActive = true
                else
                    - var menuActive = false

                li(class=classlist class=menuActive ? 'active' : '')
                    a(href=megaMenu.url class="dropdown-item")
                        i(class=megaMenu.icon)
                        = megaMenu.name
                    if (megaMenu.submenu)
                            +megaMenuSubItems(megaMenu.submenu)

mixin dropdownMenuSubItems(items)
    ul.dropdown-menu
        each submenu, j in items
            //- check if classlist exist for list item
            - var classlist1 = (submenu.classlist !== undefined) ? submenu.classlist : ''
            if (submenu.divider)
                li(class="dropdown-divider")
            else if (submenu.navheader)
                //- If menu item is navigation header
                li(class=classlist1 + " navigation-header")
                    span= submenu.navheader
            else
                if (activeMenu == submenu.slug)
                    - var submenuActive = true
                else
                    - var submenuActive = false
                li(class=submenuActive ? 'active' : '' class=classlist1 class=submenu.submenu ? 'dropdown dropdown-submenu' : '' data-menu=submenu.submenu ? 'dropdown-submenu' : '')
                    a(href=submenu.url class="dropdown-item" class=submenu.submenu ? 'dropdown-toggle' : '' data-toggle="dropdown")
                        if (submenu.icon)
                            i(class=submenu.icon)
                        if (submenu.name)
                            | #{submenu.name}
                        if (submenu.menuSubtitle)
                            span.tag.menu-sub-title= submenu.menuSubtitle
                    if (submenu.submenu)
                        +dropdownMenuSubItems(submenu.submenu)



//- Layout Blocks

//- Main Content Wrapper
mixin mainContentWrap
    .app-content(class= (centerLayout == true ? 'container center-layout mt-2' : 'content'))
        block

//- Content Wrapper
mixin contentWrapper
    .content-wrapper
        .content-header.row
            block page-header
        block

//- Menu
mixin menuBlock
    = '\n'
    //- START MENU
    = '\n'
    block main-menu
    = '\n'
    //-  END MENU
    block

//- Content
mixin contentBlock()
    .content-body
        block content

//- Fix block positions
mixin blockPositions(isContentMenu, contentLayout, sidebarPosition, sidebarSticky, sidebarFixed)
    if (isContentMenu == false && contentLayout != '1-column')
        +menuBlock

    +mainContentWrap
        if (contentLayout == '1-column')
            +contentWrapper
                +contentBlock

        if (contentLayout == '2-columns')
            +contentWrapper
                if (isContentMenu == true)
                    +menuBlock
                +contentBlock

        if (contentLayout == 'content-left-sidebar' || contentLayout == 'content-right-sidebar')
            div(class= (sidebarPosition == 'left') ? 'sidebar-left' : 'sidebar-right', class= (sidebarSticky == true ? 'sidebar-sticky' : ''), class= (sidebarFixed == true ? 'sidebar-fixed' : ''))
                .sidebar
                    block sidebar
            div(class= (sidebarPosition == 'left') ? 'content-right' : 'content-left')

                +contentWrapper
                    if (isContentMenu == true)
                        +menuBlock
                    +contentBlock

        if (contentLayout == 'content-detached-left-sidebar' || contentLayout == 'content-detached-right-sidebar')
            +contentWrapper
                if (isContentMenu == true)
                    +menuBlock
                div.content-detached(class= (sidebarPosition == 'left') ? 'content-right' : 'content-left')
                    .content-body
                        block content
                div.sidebar-detached(class= (sidebarPosition == 'left') ? 'sidebar-left' : 'sidebar-right', class= (sidebarSticky == true) ? 'sidebar-sticky' : '', , class= (sidebarFixed == true) ? 'sidebar-fixed' : '')
                    div.sidebar
                        block sidebar

//- Page Layouts
mixin pageLayouts(contentLayout, sidebarSticky, sidebarFixed, isContentMenu)

    if ( contentLayout == 'content-left-sidebar' )
        +blockPositions(isContentMenu, contentLayout, 'left', sidebarSticky, sidebarFixed)
    else if ( contentLayout == 'content-right-sidebar' )
        +blockPositions(isContentMenu, contentLayout, 'right', sidebarSticky, sidebarFixed)
    else if ( contentLayout == 'content-detached-left-sidebar' )
        +blockPositions(isContentMenu, contentLayout, 'left', sidebarSticky, sidebarFixed)
    else if ( contentLayout == 'content-detached-right-sidebar' )
        +blockPositions(isContentMenu, contentLayout, 'right', sidebarSticky, sidebarFixed)
    else
        +blockPositions(isContentMenu, contentLayout)
